﻿@{
    ViewBag.Title = "Form"; 
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    //父传子示例
    function initForm(data) {
        layui.use(['common'], function () {
            var common = layui.common;
            common.val('adminform',data);
        });
    }
    layui.use(['jquery', 'form', 'laydate', 'optimizeSelectOption', 'common'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            laydate = layui.laydate;
        var keyValue = $.request("keyValue");
        //权限字段
        common.authorizeFields('adminform');
        //此处需修改
        //类型为时间时
        //laydate.render({
            //elem: '#F_Birthday'
            //, btns: ['clear', 'now']
            //, trigger: 'click',
            //format: 'yyyy-MM-dd',
        //});

        $(function () {
            initControl();
            form.render();
       });
        wcLoading.close();
       function initControl() {
           //此处需修改
           //绑定数据源
           //类型为下拉框时
           $("#F_ParentId").bindSelect({
               url: "/ContentManage/ArticleCategory/GetListJson",
               id: "F_Id",
               text: "F_FullName",
               search: true,
           });
       }

       //监听提交
        form.on('submit(saveBtn)', function (data) {
            // 单击之后提交按钮不可选,防止重复提交
            $('.site-demo-active').addClass('layui-btn-disabled');
            $('.site-demo-active').attr('disabled', 'disabled');
           var postData = data.field;
           if (!postData["F_IsTop"]) postData["F_IsTop"] = false;
           if (!postData["F_IsHot"]) postData["F_IsHot"] = false;
           if (!postData["F_EnabledMark"]) postData["F_EnabledMark"] = false;
           common.submitForm({
               url: '/ContentManage/ArticleCategory/SubmitForm?keyValue=' + keyValue,
               param: postData,
               success: function () {
                   common.parentreload('data-search-btn');
               }
           })
           return false;
       });
   });
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">类别名称</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_FullName" name="F_FullName" autocomplete="off" maxlength="50" lay-verify="required" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">上级</label>
                   <div class="layui-input-block">
                       <select id="F_ParentId" name="F_ParentId" lay-filter="F_ParentId" lay-verify="required" lay-search>
                           <option value="0">父级</option>
                       </select>
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">排序</label>
                   <div class="layui-input-block">
                       <input type="number" pattern="[0-9]*" id="F_SortCode" name="F_SortCode" lay-verify="required|number"  oninput="if(value.length>8)value=value.slice(0,8)" value="99"  autocomplete="off" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label">描述</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_Description" name="F_Description" autocomplete="off" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label">链接地址</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_LinkUrl" name="F_LinkUrl" autocomplete="off" lay-verify="url" maxlength="255" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label">图片地址</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_ImgUrl" name="F_ImgUrl" autocomplete="off" lay-verify="url" maxlength="255" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label">Seo标题</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_SeoTitle" name="F_SeoTitle" autocomplete="off"  maxlength="255" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label">Seo关键字</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_SeoKeywords" name="F_SeoKeywords" autocomplete="off" maxlength="255" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label">Seo描述</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_SeoDescription" name="F_SeoDescription" autocomplete="off" maxlength="255" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">选项</label>
                    <div class="layui-input-block">
                        <input id="F_IsTop" name="F_IsTop" type="checkbox" value="true" title="是否置顶">
                        <input id="F_IsHot" name="F_IsHot" type="checkbox" value="true" title="是否热门">
                        <input id="F_EnabledMark" name="F_EnabledMark" type="checkbox" value="true" checked="checked" title="是否启用">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <button class="layui-btn site-demo-active" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>

